package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anotation.AutoFill;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {
    @Insert("insert into category(id, type, name, sort, status, create_time," + " update_time, create_user, update_user) " + "values (#{id} ,#{type},#{name},#{sort}," + "#{status},#{createTime} ,#{updateTime},#{createUser},#{updateUser} )")
    @AutoFill(value = OperationType.INSERT)
    void insert(Category category);

    Page<Category> getPage(String name, Integer type);

    @Select("select * from category where id=#{id} ;")
    Category getById(Integer id);

    @AutoFill(value=OperationType.UPDATE)
    void update(Category c);

    @Delete("delete from category  where id=#{id}")
    void delete(Long id);

    List<Category> list(Integer type);
}
